﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Admin_Module.aspx.cs" Inherits="Xiaov.SmartWeb.Application.SysAdmin.Admin_Module" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" type="text/css" href="../Resources/xiaovcn/css/ssec-form.css"/>
    <script type="text/javascript" src="../Resources/xiaovcn/scripts/common.js" ></script>
    <script type="text/javascript" src="/Resources/xiaovcn/scripts/usercheck.js"></script>
    <script type="text/javascript">

        function callback(res) {
            if (res.value) {
                $('#t3').combotree('reload');
                $('#tt').treegrid('reload');
                $('#add').window('close');
                $.messager.alert('提示', '操作成功！');
            }
            else {
                $.messager.alert('提示', '操作失败！');
            }
        }

        

        function save() {            
            var a = $('#t1').val();
            var b = $('#t2').val();
            var c = $('#t3').combotree('getValue');
            var d = $('#t4').val();
            var d_1 = $('#t4_1').combotree('getValue');
            var e = $('#t5').val();
            var f = $('#t6').attr("checked");
            var g = $('#t7').attr("checked");
            var h = $('#t8').val();
            var i = $('#t9').val();
            Xiaov.SmartWeb.Application.SysAdmin.Admin_Module.Save(a, b, c, d, d_1, e, f, g, h, i, callback);            
        }

        function del(node) {
            Xiaov.SmartWeb.Application.SysAdmin.Admin_Module.DeleteNode(node.MODULEID, callback);
        }
        
        function clear(node) {
            Xiaov.SmartWeb.Application.SysAdmin.Admin_Module.ClearNode(node.MODULEID, callback);
        }

        function loadCombotree() {
            $('#t3').combotree({ url: 'Json/Module.aspx?t=combotree' });
        }

        $(function () {
            loadCombotree();
            $('#tt').treegrid({
                title: '系统模块列表',
                url: 'Json/Module.aspx?t=treegrid',
                iconCls: 'icon-applicationgo',
                nowrap: true,
                rownumbers: true,
                animate: false,
                collapsible: false,
                singleSelect: true,
                remoteSort: false,
                idField: 'MODULEID',
                treeField: 'MODULENAME',
                columns: [[
                         { field: 'MODULEID', title: '编码', width: 50 },
                         { field: 'MODULENAME', title: '名称', sortable: true, width: 200, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'MODULEURL', title: '地址', width: 200, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'ACTIONSTRING', title: '权限', width: 200, rowspan: 2, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'SHOW', title: '显示', width: 50, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'DISABLED', title: '禁用', width: 50, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'SORTBY', title: '排序', sortable: true, width: 50, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'MCOMMENT', title: '备注', width: 100, formatter: function (val, rec) { return unescape(val) } }
                ]],
                toolbar: [{
                    text: '新增同级节点',
                    iconCls: 'icon-add',
                    handler: function () {
                        clearForm();//重置表单
                        $('#t3').attr("disabled", "disabled");
                        var node = $('#tt').treegrid('getSelected');
                        if (node != null) {
                            //弹出窗口
                            $('#t3').combotree('setValue', node.PARENTMODULEID);
                        }
                        $('#add').window('open');
                    }
                }, '-', {
                    text: '增加子节点',
                    iconCls: 'icon-add',
                    handler: function () {
                        clearForm();//重置表单
                        $('#t3').attr("disabled", "disabled");
                        var node = $('#tt').treegrid('getSelected');
                        if (node != null) {
                            //弹出窗口
                            $('#t3').combotree('setValue', node.MODULEID);
                        }
                        $('#add').window('open');
                    }
                }, '-', {
                    text: '修改节点',
                    iconCls: 'icon-edit',
                    handler: function () {
                        editrow();
                    }
                }, '-', {
                    text: '删除节点',
                    iconCls: 'icon-remove',
                    handler: function () {
                        var node = $('#tt').treegrid('getSelected');
                        var nodes;
                        if (node) {
                            nodes = $('#tt').treegrid('getChildren', node.MODULEID);
                            if (nodes.length > 0) {
                                $.messager.confirm('提示', '当前节点还有(' + nodes.length + ')个子节点，要一并删除吗？', function (r) {
                                    if (r) {
                                        clear(node);
                                    }
                                });
                            }
                            else {
                                $.messager.confirm('提示', '确定要删除【' + unescape(node.MODULENAME) + '】这个模块吗?', function (r) {
                                    if (r) {
                                        del(node);
                                    }
                                });
                            }
                        }
                        else
                            alert('请选中一个节点');
                    }
                }],
                onLoadSuccess: function () {
                    $('#mask').fadeOut('slow');
                    
                }
            });
        });

        function editrow(){
            var node = $('#tt').treegrid('getSelected');
            if (node) {
                //修改
                $('#t1').attr('value', node.MODULEID);
                $('#t2').attr('value', unescape(node.MODULENAME));
                $('#t3').combotree('setValue', node.PARENTMODULEID);
                $('#t4').attr('value', unescape(node.MODULEURL));
                $('#t5').attr('value', unescape(node.ACTIONSTRING));
                if(node.SHOW=="1")
                    $('#t6').attr('checked', true);
                else
                    $('#t6').attr('checked', false);

                if (node.DISABLED == "1")
                    $('#t7').attr('checked', true);
                else
                    $('#t7').attr('checked', false);

                            
                $('#t8').attr('value', node.SORTBY);
                $('#t9').attr('value', unescape(node.MCOMMENT));
                $('#add').window('open');
            }
            else
                alert('请选中一个节点');
        }
        
</script>   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">    
    <table id="tt">
    </table> 
    <script>
        $('#tt').css('height',userScreenHeight+20);
    </script>
    <div id="add" class="easyui-window" closed="true" modal="true" maximized="true"  title="模块信息" style="width:400px; " >
        <div id="contents" class="ssec-form">
        <div class="ssec-group ssec-group-hasicon"><img src="../Resources/easyui-1.32/themes/icons/mini_add.png" alt=""/>模块信息</div>
            <table>
            <tr>
                <td><div class="ssec-label">模块ID：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t1" ClientIDMode="Static" runat="server" CssClass="ssec-text-field" Enabled="false"></asp:TextBox></div></td>             
           </tr> 
            <tr>   
                <td><div class="ssec-label">模块名称：</div></td>
                <td><div class="ssec-text large" style="float:left; width:300px;"><asp:TextBox ID="t2" ClientIDMode="Static" runat="server" CssClass="ssec-text-field easyui-validatebox"  required="true" ></asp:TextBox></div>
                    <div style="float:left; line-height:23px;color:#b2a6a6">
                    &nbsp;&nbsp;《=选择报表：&nbsp;<input class="easyui-combobox" style="color:#b2a6a6"
                        data-options="
                        width:370,
                        valueField:'id',
                        textField:'text',
                        url:'/PluginSrc/StatisticalSystem/ReportDesign/Json/BBBMB.aspx',
                         onSelect: function(rec){
                            var url = '/PluginSrc/StatisticalSystem/CommReport.aspx?tn='+rec.id;
                            $('#t4').empty().val(url);
                           // $('#t2').empty().val(rec.text.replace(/（[^）]+）/g, ''));
                           
                            var start=rec.text.indexOf('[');
                             var end=rec.text.indexOf(']');
                             var mc=rec.text.substring(0,start)+rec.text.substring(end+1,rec.text.length);
                             $('#t2').empty().val(mc);
                        }

                        
                        " style="line-height:23px;"/></div>
                    
                    <div></div>
                </td>
            </tr>   
            <tr>   
                <td><div class="ssec-label">上级节点：</div></td>
                <td><div><asp:TextBox ID="t3" ClientIDMode="Static" runat="server" class="easyui-combotree"  panelHeight="300px" panelWidth="300px"></asp:TextBox></div></td>
            </tr> 
            <tr>   
                <td><div class="ssec-label">访问URL：</div></td>
                <td><div class="ssec-text large"><asp:TextBox ID="t4" ClientIDMode="Static" runat="server" CssClass="ssec-text-field" Text="/PluginSrc/StatisticalSystem/CommReport.aspx?tn=" ></asp:TextBox></div></td>
            </tr>
             <tr>   
                <td><div class="ssec-label">URL打开方式：</div></td>
                <td><div>
                    <asp:DropDownList ID="t4_1"  ClientIDMode="Static" runat="server"  CssClass="easyui-combobox" panelHeight="auto">
                    <asp:ListItem Text="mainframe" Value="mainframe"></asp:ListItem>
                    <asp:ListItem Text="_blank" Value="_blank"></asp:ListItem>  
                    <asp:ListItem Text="_self" Value="_self"></asp:ListItem>                    
                    <asp:ListItem Text="_parent" Value="_parent"></asp:ListItem> 
                    <asp:ListItem Text="_top" Value="_top"></asp:ListItem>                   
                    </asp:DropDownList>
                </div></td>
            </tr>
            <tr>   
                <td><div class="ssec-label">权限描述：</div></td>
                <td><div class="ssec-text  large" style="float:left;"><asp:TextBox ID="t5" ClientIDMode="Static" runat="server" CssClass="ssec-text-field" ></asp:TextBox></div>
                    <div style="float:left;">
                    &nbsp;<a href="#" onclick="add_tjqx();" style="line-height:23px;"> 点击生成统计报表权限</a></div></td>
                
                <script>
                    function add_tjqx()
                    {
                        $('#t5').empty().val('新增行,新增子节点,删除行,保存,清空,计算,提取,汇总,继承');
                    }
                </script>
            </tr>
            <tr>   
                <td><div class="ssec-label">是否显示：</div></td>
                <td><asp:CheckBox ID="t6" runat="server" ClientIDMode="Static" Checked="true" /></td>
            </tr>
            <tr>   
                <td><div class="ssec-label">禁用：</div></td>
                <td><asp:CheckBox ID="t7" runat="server" ClientIDMode="Static" /></td>
            </tr>
            <tr>   
                <td><div class="ssec-label">排序：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t8" ClientIDMode="Static" runat="server" CssClass="ssec-text-field"></asp:TextBox></div></td>
            </tr>   
            <tr>   
                <td><div class="ssec-label">备注描述：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t9" ClientIDMode="Static" runat="server" CssClass="ssec-text-field"></asp:TextBox></div></td>
            </tr>
                </table>
           <div style="text-align:left; padding:5px"><a  class="easyui-linkbutton" iconCls="icon-save"  onclick="save();">保存</a></div>   
     
       </div>
    </div>
</asp:Content>
